# $Id: PKGBUILD 88219 2013-04-14 15:14:40Z arodseth $
# Maintainer: Alexander Rødseth <rodseth@gmail.com>
# Contributor: Musikolo <musikoloAThotmailDOTcom>
# Contributor: krani1
# Contributor: Andreas W. Hauser <andy-aur@splashground.de>

pkgname=groovy
pkgver=2.1.3
pkgrel=1
pkgdesc='Programming language based on Java, inspired by Python, Ruby and Smalltalk'
arch=('any')
url='http://groovy.codehaus.org/'
license=('APACHE' 'BSD' 'custom')
depends=('bash' 'java-environment')
optdepends=('groovy-docs: html and pdf documentation for Groovy')
makedepends=('unzip')
source=("http://dist.groovy.codehaus.org/distributions/$pkgname-binary-$pkgver.zip")
sha256sums=('c8379e19da3f672036d0a9f7383fe7ba143276066077bff29d50c6cbab3f8c0b')

prepare() {
  cd "$srcdir/$pkgname-$pkgver/embeddable"

  ln -s "$pkgname-all-$pkgver.jar" "$pkgname-all.jar"
  for f in ../bin/*; do
    sed 's:bin/sh:bin/sh\nGROOVY_HOME=/usr/share/groovy:' -i $f
  done
}

package() {
  cd "$srcdir/$pkgname-$pkgver"

  mkdir -p "$pkgdir/usr/share/groovy" "$pkgdir/usr/bin"
  cp -r lib "$pkgdir/usr/share/groovy"
  cp -r conf "$pkgdir/usr/share/groovy"
  cp -r embeddable "$pkgdir/usr/share/groovy"
  cp bin/* "$pkgdir/usr/bin"
  find $pkgdir -name '*.bat' -exec rm {} \;
  # APACHE
  install -Dm644 LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm644 CLI-LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/CLI-LICENSE"
  # BSD
  install -Dm644 ANTLR-LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/ANTLR-LICENSE"
  # custom
  install -Dm644 ASM-LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/ASM-LICENSE"
  install -Dm644 JSR223-LICENSE.txt \
    "$pkgdir/usr/share/licenses/$pkgname/JSR223-LICENSE"
}

# vim:set ts=2 sw=2 et:
